Skip to content

[Bug Fix] Accordion clips content that grows after opening - #500

Merged
djalmaaraujo merged 1 commit into
ruby-ui:mainfrom
pierry01:fix/accordion-height-auto-after-open
Aug 5, 2026
Merged

[Bug Fix] Accordion clips content that grows after opening#500
djalmaaraujo merged 1 commit into
ruby-ui:mainfrom
pierry01:fix/accordion-height-auto-after-open

Conversation

@pierry01

@pierry01 pierry01 commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Related issue

No existing issue — happy to open one if you'd prefer to track it separately.

Description

revealContent() measures scrollHeight at open time and animates the panel to that fixed pixel height. The inline height then stays frozen, so any content that grows after the panel is already open — a lazy-loaded iframe/image, an async-rendered row, a nested control that expands — is clipped by the panel's fixed height + overflow.

This fix makes the panel resilient to content that changes after opening:

  • revealContent() — once the open animation finishes (and the item is still open), release the fixed height back to height: auto, so the panel tracks its content instead of freezing at the height measured on open.
  • hideContent() — collapse from the element's current rendered height (getBoundingClientRect().height) via an explicit [from, "0px"] keyframe. Motion can't interpolate from auto, so an explicit start is required now that the open state is auto. Using the current height (not scrollHeight) also avoids a jump-to-full-height on fast open→close toggles.
  • A .catch(() => {}) guards the new finished promise on revealContent (closing mid-open-animation rejects it).

The open/close animation is visually unchanged — only the resting open state goes from a fixed pixel height to auto. The existing hidden-attribute and data-state behavior is preserved.

@pierry01
pierry01 requested a review from cirdes as a code owner August 5, 2026 14:25
revealContent froze the panel at the height measured on open, so content that
appears after opening (lazy-loaded iframes/images, expanding rows) was clipped.
Release the height to `auto` once the open animation finishes, and collapse from
the current rendered height since Motion can't interpolate from `auto`.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@pierry01
pierry01 force-pushed the fix/accordion-height-auto-after-open branch from aa50fed to f374c23 Compare August 5, 2026 14:35
@pierry01 pierry01 self-assigned this Aug 5, 2026
@pierry01
pierry01 requested a review from djalmaaraujo August 5, 2026 14:42
@djalmaaraujo
djalmaaraujo merged commit 43bc039 into ruby-ui:main Aug 5, 2026
8 checks passed
djalmaaraujo added a commit that referenced this pull request Aug 5, 2026
Bump RubyUI to 1.6.0 (minor: new component + new component options since v1.5.0).

- gem/lib/ruby_ui.rb → 1.6.0; regenerate gem/ and docs/ Gemfile.lock
- docs home hero badge → headline features (InputOtp, Combobox placement)
- rebuild mcp/data/registry.json

Highlights since v1.5.0:
- New component: InputOtp (#456)
- Combobox: configurable popover placement (#480), CheckboxGroup reuse for required ComboboxCheckbox (#479)
- DataTable: custom label + initial column visibility in DataTableColumnToggle (#466)
- Popover: data-state/data-side, clear closeTimeout on disconnect, close on Escape (#495)
- Accordion: no longer clips content that grows after opening (#500, #490)
- Toast: toaster state initialized in initialize() so server-rendered toasts don't throw (#499)
- Docs: Stimulus controllers symlinked to gem source, no more hand-copied drift (#493)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants